.class public Lorg/microemu/util/ThreadUtils;
.super Ljava/lang/Object;
.source "ThreadUtils.java"


# static fields
.field static class$java$lang$String:Ljava/lang/Class;

.field static class$java$util$Timer:Ljava/lang/Class;

.field private static java13:Z

.field private static java14:Z


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 35
    sput-boolean v0, Lorg/microemu/util/ThreadUtils;->java13:Z

    .line 37
    sput-boolean v0, Lorg/microemu/util/ThreadUtils;->java14:Z

    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 33
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method static class$(Ljava/lang/String;)Ljava/lang/Class;
    .locals 2
    .parameter "x0"

    .prologue
    .line 47
    :try_start_0
    invoke-static {p0}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
    :try_end_0
    .catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    return-object v1

    :catch_0
    move-exception v0

    .local v0, x1:Ljava/lang/ClassNotFoundException;
    new-instance v1, Ljava/lang/NoClassDefFoundError;

    invoke-direct {v1}, Ljava/lang/NoClassDefFoundError;-><init>()V

    invoke-virtual {v1, v0}, Ljava/lang/NoClassDefFoundError;->initCause(Ljava/lang/Throwable;)Ljava/lang/Throwable;

    move-result-object v1

    throw v1
.end method

.method public static createTimer(Ljava/lang/String;)Ljava/util/Timer;
    .locals 6
    .parameter "name"

    .prologue
    .line 47
    :try_start_0
    sget-object v2, Lorg/microemu/util/ThreadUtils;->class$java$util$Timer:Ljava/lang/Class;

    if-nez v2, :cond_0

    const-string v2, "java.util.Timer"

    invoke-static {v2}, Lorg/microemu/util/ThreadUtils;->class$(Ljava/lang/String;)Ljava/lang/Class;

    move-result-object v2

    sput-object v2, Lorg/microemu/util/ThreadUtils;->class$java$util$Timer:Ljava/lang/Class;

    :goto_0
    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Class;

    const/4 v4, 0x0

    sget-object v5, Lorg/microemu/util/ThreadUtils;->class$java$lang$String:Ljava/lang/Class;

    if-nez v5, :cond_1

    const-string v5, "java.lang.String"

    invoke-static {v5}, Lorg/microemu/util/ThreadUtils;->class$(Ljava/lang/String;)Ljava/lang/Class;

    move-result-object v5

    sput-object v5, Lorg/microemu/util/ThreadUtils;->class$java$lang$String:Ljava/lang/Class;

    :goto_1
    aput-object v5, v3, v4

    invoke-virtual {v2, v3}, Ljava/lang/Class;->getConstructor([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;

    move-result-object v0

    .line 48
    .local v0, c:Ljava/lang/reflect/Constructor;
    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    aput-object p0, v2, v3

    invoke-virtual {v0, v2}, Ljava/lang/reflect/Constructor;->newInstance([Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object p0

    .end local p0
    check-cast p0, Ljava/util/Timer;

    move-object v2, p0

    .line 51
    .end local v0           #c:Ljava/lang/reflect/Constructor;
    :goto_2
    return-object v2

    .line 47
    .restart local p0
    :cond_0
    sget-object v2, Lorg/microemu/util/ThreadUtils;->class$java$util$Timer:Ljava/lang/Class;

    goto :goto_0

    :cond_1
    sget-object v5, Lorg/microemu/util/ThreadUtils;->class$java$lang$String:Ljava/lang/Class;
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    .line 49
    .end local p0
    :catch_0
    move-exception v2

    move-object v1, v2

    .line 51
    .local v1, e:Ljava/lang/Throwable;
    new-instance v2, Ljava/util/Timer;

    invoke-direct {v2}, Ljava/util/Timer;-><init>()V

    goto :goto_2
.end method

.method public static getCallLocation(Ljava/lang/String;)Ljava/lang/String;
    .locals 7
    .parameter "fqn"

    .prologue
    const/4 v6, 0x1

    .line 56
    sget-boolean v5, Lorg/microemu/util/ThreadUtils;->java13:Z

    if-nez v5, :cond_2

    .line 58
    :try_start_0
    new-instance v5, Ljava/lang/Throwable;

    invoke-direct {v5}, Ljava/lang/Throwable;-><init>()V

    invoke-virtual {v5}, Ljava/lang/Throwable;->getStackTrace()[Ljava/lang/StackTraceElement;

    move-result-object v4

    .line 59
    .local v4, ste:[Ljava/lang/StackTraceElement;
    const/4 v2, 0x0

    .local v2, i:I
    :goto_0
    array-length v5, v4

    sub-int/2addr v5, v6

    if-ge v2, v5, :cond_2

    .line 60
    aget-object v5, v4, v2

    invoke-virtual {v5}, Ljava/lang/StackTraceElement;->getClassName()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {p0, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 61
    add-int/lit8 v5, v2, 0x1

    aget-object v0, v4, v5

    .line 62
    .local v0, callLocation:Ljava/lang/StackTraceElement;
    invoke-virtual {v0}, Ljava/lang/StackTraceElement;->getClassName()Ljava/lang/String;

    move-result-object v3

    .line 63
    .local v3, nextClassName:Ljava/lang/String;
    invoke-virtual {v3, p0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 59
    .end local v0           #callLocation:Ljava/lang/StackTraceElement;
    .end local v3           #nextClassName:Ljava/lang/String;
    :cond_0
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 66
    .restart local v0       #callLocation:Ljava/lang/StackTraceElement;
    .restart local v3       #nextClassName:Ljava/lang/String;
    :cond_1
    invoke-virtual {v0}, Ljava/lang/StackTraceElement;->toString()Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v5

    .line 73
    .end local v4           #ste:[Ljava/lang/StackTraceElement;
    .end local v2           #i:I
    .end local v0           #callLocation:Ljava/lang/StackTraceElement;
    .end local v3           #nextClassName:Ljava/lang/String;
    :goto_1
    return-object v5

    .line 69
    :catch_0
    move-exception v5

    move-object v1, v5

    .line 70
    .local v1, e:Ljava/lang/Throwable;
    sput-boolean v6, Lorg/microemu/util/ThreadUtils;->java13:Z

    .line 73
    .end local v1           #e:Ljava/lang/Throwable;
    :cond_2
    const/4 v5, 0x0

    goto :goto_1
.end method

.method public static getTreadStackTrace(Ljava/lang/Thread;)Ljava/lang/String;
    .locals 10
    .parameter "t"

    .prologue
    const-string v9, ""

    .line 77
    sget-boolean v6, Lorg/microemu/util/ThreadUtils;->java14:Z

    if-eqz v6, :cond_0

    .line 78
    const-string v6, ""

    move-object v6, v9

    .line 92
    .end local p0
    :goto_0
    return-object v6

    .line 82
    .restart local p0
    :cond_0
    :try_start_0
    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v6

    const-string v7, "getStackTrace"

    const/4 v8, 0x0

    invoke-virtual {v6, v7, v8}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;

    move-result-object v4

    .line 84
    .local v4, m:Ljava/lang/reflect/Method;
    const/4 v6, 0x0

    invoke-virtual {v4, p0, v6}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object p0

    .end local p0
    check-cast p0, [Ljava/lang/StackTraceElement;

    move-object v0, p0

    check-cast v0, [Ljava/lang/StackTraceElement;

    move-object v5, v0

    .line 85
    .local v5, trace:[Ljava/lang/StackTraceElement;
    new-instance v1, Ljava/lang/StringBuffer;

    invoke-direct {v1}, Ljava/lang/StringBuffer;-><init>()V

    .line 86
    .local v1, b:Ljava/lang/StringBuffer;
    const/4 v3, 0x0

    .local v3, i:I
    :goto_1
    array-length v6, v5

    if-ge v3, v6, :cond_1

    .line 87
    const-string v6, "\n\tat "

    invoke-virtual {v1, v6}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v6

    aget-object v7, v5, v3

    invoke-virtual {v6, v7}, Ljava/lang/StringBuffer;->append(Ljava/lang/Object;)Ljava/lang/StringBuffer;

    .line 86
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    .line 89
    :cond_1
    invoke-virtual {v1}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v6

    goto :goto_0

    .line 90
    .end local v4           #m:Ljava/lang/reflect/Method;
    .end local v5           #trace:[Ljava/lang/StackTraceElement;
    .end local v1           #b:Ljava/lang/StringBuffer;
    .end local v3           #i:I
    :catch_0
    move-exception v6

    move-object v2, v6

    .line 91
    .local v2, e:Ljava/lang/Throwable;
    const/4 v6, 0x1

    sput-boolean v6, Lorg/microemu/util/ThreadUtils;->java14:Z

    .line 92
    const-string v6, ""

    move-object v6, v9

    goto :goto_0
.end method
